{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "39647536",
   "metadata": {},
   "source": [
    "#  回顾复习（for+range)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "81791e28",
   "metadata": {},
   "source": [
    "## for循环"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "f29da0a9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in [1,2,3,4]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3dcf3fe4",
   "metadata": {},
   "source": [
    "## range\n",
    "* 目标：创建有序数值（创建自然数）\n",
    "* range的start数值默认为0，step默认为1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "fed76976",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(0, 5)"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "8c326b07",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4]"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(0,5)) # 产生了0-5个值，默认从0开始 注：0（start） 5（stop） 每一次增长1个单位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "41fbe031",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(2, 5)"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(2,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "f06add29",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, 3, 4]"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(2,5)) # 产生了5-2个值，start=2，stop=5，每一次增长1个单位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "8def939c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(1, 10, 3)"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(1,10,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "fabf23ba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 7]"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(1,10,3)) # start=1，stop=10，每一次增长3个单位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "0090b579",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/xxyw/index0.htm\n",
      "https://www.nfu.edu.cn/xxyw/index1.htm\n",
      "https://www.nfu.edu.cn/xxyw/index2.htm\n",
      "https://www.nfu.edu.cn/xxyw/index3.htm\n",
      "https://www.nfu.edu.cn/xxyw/index4.htm\n",
      "https://www.nfu.edu.cn/xxyw/index5.htm\n",
      "https://www.nfu.edu.cn/xxyw/index6.htm\n",
      "https://www.nfu.edu.cn/xxyw/index7.htm\n",
      "https://www.nfu.edu.cn/xxyw/index8.htm\n",
      "https://www.nfu.edu.cn/xxyw/index9.htm\n",
      "https://www.nfu.edu.cn/xxyw/index10.htm\n",
      "https://www.nfu.edu.cn/xxyw/index11.htm\n",
      "https://www.nfu.edu.cn/xxyw/index12.htm\n",
      "https://www.nfu.edu.cn/xxyw/index13.htm\n",
      "https://www.nfu.edu.cn/xxyw/index14.htm\n",
      "https://www.nfu.edu.cn/xxyw/index15.htm\n",
      "https://www.nfu.edu.cn/xxyw/index16.htm\n",
      "https://www.nfu.edu.cn/xxyw/index17.htm\n",
      "https://www.nfu.edu.cn/xxyw/index18.htm\n",
      "https://www.nfu.edu.cn/xxyw/index19.htm\n",
      "https://www.nfu.edu.cn/xxyw/index20.htm\n",
      "https://www.nfu.edu.cn/xxyw/index21.htm\n",
      "https://www.nfu.edu.cn/xxyw/index22.htm\n",
      "https://www.nfu.edu.cn/xxyw/index23.htm\n",
      "https://www.nfu.edu.cn/xxyw/index24.htm\n",
      "https://www.nfu.edu.cn/xxyw/index25.htm\n",
      "https://www.nfu.edu.cn/xxyw/index26.htm\n",
      "https://www.nfu.edu.cn/xxyw/index27.htm\n",
      "https://www.nfu.edu.cn/xxyw/index28.htm\n",
      "https://www.nfu.edu.cn/xxyw/index29.htm\n",
      "https://www.nfu.edu.cn/xxyw/index30.htm\n",
      "https://www.nfu.edu.cn/xxyw/index31.htm\n",
      "https://www.nfu.edu.cn/xxyw/index32.htm\n",
      "https://www.nfu.edu.cn/xxyw/index33.htm\n",
      "https://www.nfu.edu.cn/xxyw/index34.htm\n",
      "https://www.nfu.edu.cn/xxyw/index35.htm\n",
      "https://www.nfu.edu.cn/xxyw/index36.htm\n",
      "https://www.nfu.edu.cn/xxyw/index37.htm\n",
      "https://www.nfu.edu.cn/xxyw/index38.htm\n",
      "https://www.nfu.edu.cn/xxyw/index39.htm\n",
      "https://www.nfu.edu.cn/xxyw/index40.htm\n",
      "https://www.nfu.edu.cn/xxyw/index41.htm\n",
      "https://www.nfu.edu.cn/xxyw/index42.htm\n",
      "https://www.nfu.edu.cn/xxyw/index43.htm\n",
      "https://www.nfu.edu.cn/xxyw/index44.htm\n",
      "https://www.nfu.edu.cn/xxyw/index45.htm\n",
      "https://www.nfu.edu.cn/xxyw/index46.htm\n",
      "https://www.nfu.edu.cn/xxyw/index47.htm\n",
      "https://www.nfu.edu.cn/xxyw/index48.htm\n",
      "https://www.nfu.edu.cn/xxyw/index49.htm\n",
      "https://www.nfu.edu.cn/xxyw/index50.htm\n",
      "https://www.nfu.edu.cn/xxyw/index51.htm\n",
      "https://www.nfu.edu.cn/xxyw/index52.htm\n",
      "https://www.nfu.edu.cn/xxyw/index53.htm\n",
      "https://www.nfu.edu.cn/xxyw/index54.htm\n",
      "https://www.nfu.edu.cn/xxyw/index55.htm\n",
      "https://www.nfu.edu.cn/xxyw/index56.htm\n",
      "https://www.nfu.edu.cn/xxyw/index57.htm\n",
      "https://www.nfu.edu.cn/xxyw/index58.htm\n",
      "https://www.nfu.edu.cn/xxyw/index59.htm\n",
      "https://www.nfu.edu.cn/xxyw/index60.htm\n",
      "https://www.nfu.edu.cn/xxyw/index61.htm\n",
      "https://www.nfu.edu.cn/xxyw/index62.htm\n",
      "https://www.nfu.edu.cn/xxyw/index63.htm\n",
      "https://www.nfu.edu.cn/xxyw/index64.htm\n",
      "https://www.nfu.edu.cn/xxyw/index65.htm\n",
      "https://www.nfu.edu.cn/xxyw/index66.htm\n",
      "https://www.nfu.edu.cn/xxyw/index67.htm\n",
      "https://www.nfu.edu.cn/xxyw/index68.htm\n",
      "https://www.nfu.edu.cn/xxyw/index69.htm\n",
      "https://www.nfu.edu.cn/xxyw/index70.htm\n",
      "https://www.nfu.edu.cn/xxyw/index71.htm\n",
      "https://www.nfu.edu.cn/xxyw/index72.htm\n",
      "https://www.nfu.edu.cn/xxyw/index73.htm\n",
      "https://www.nfu.edu.cn/xxyw/index74.htm\n",
      "https://www.nfu.edu.cn/xxyw/index75.htm\n",
      "https://www.nfu.edu.cn/xxyw/index76.htm\n",
      "https://www.nfu.edu.cn/xxyw/index77.htm\n",
      "https://www.nfu.edu.cn/xxyw/index78.htm\n",
      "https://www.nfu.edu.cn/xxyw/index79.htm\n",
      "https://www.nfu.edu.cn/xxyw/index80.htm\n",
      "https://www.nfu.edu.cn/xxyw/index81.htm\n",
      "https://www.nfu.edu.cn/xxyw/index82.htm\n",
      "https://www.nfu.edu.cn/xxyw/index83.htm\n",
      "https://www.nfu.edu.cn/xxyw/index84.htm\n",
      "https://www.nfu.edu.cn/xxyw/index85.htm\n",
      "https://www.nfu.edu.cn/xxyw/index86.htm\n",
      "https://www.nfu.edu.cn/xxyw/index87.htm\n",
      "https://www.nfu.edu.cn/xxyw/index88.htm\n",
      "https://www.nfu.edu.cn/xxyw/index89.htm\n",
      "https://www.nfu.edu.cn/xxyw/index90.htm\n",
      "https://www.nfu.edu.cn/xxyw/index91.htm\n",
      "https://www.nfu.edu.cn/xxyw/index92.htm\n",
      "https://www.nfu.edu.cn/xxyw/index93.htm\n",
      "https://www.nfu.edu.cn/xxyw/index94.htm\n",
      "https://www.nfu.edu.cn/xxyw/index95.htm\n",
      "https://www.nfu.edu.cn/xxyw/index96.htm\n",
      "https://www.nfu.edu.cn/xxyw/index97.htm\n",
      "https://www.nfu.edu.cn/xxyw/index98.htm\n",
      "https://www.nfu.edu.cn/xxyw/index99.htm\n",
      "https://www.nfu.edu.cn/xxyw/index100.htm\n",
      "https://www.nfu.edu.cn/xxyw/index101.htm\n",
      "https://www.nfu.edu.cn/xxyw/index102.htm\n",
      "https://www.nfu.edu.cn/xxyw/index103.htm\n",
      "https://www.nfu.edu.cn/xxyw/index104.htm\n",
      "https://www.nfu.edu.cn/xxyw/index105.htm\n",
      "https://www.nfu.edu.cn/xxyw/index106.htm\n",
      "https://www.nfu.edu.cn/xxyw/index107.htm\n",
      "https://www.nfu.edu.cn/xxyw/index108.htm\n",
      "https://www.nfu.edu.cn/xxyw/index109.htm\n"
     ]
    }
   ],
   "source": [
    "### 实战练习：快速生成 某个网站的所有代码的URL队列\n",
    "南方学院学校要闻 = \"https://www.nfu.edu.cn/xxyw/index\"\n",
    "\n",
    "页面后缀 = \".htm\"\n",
    "page = 110\n",
    "\n",
    "for i in range(page):\n",
    "    print(南方学院学校要闻 + str(i) + 页面后缀)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "b2147bb4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 总结：for+range   for可以执行循环，range决定了循环体的执行次数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95d5f316",
   "metadata": {},
   "source": [
    "* 日期：2022.9.14（week 4）\n",
    "* 记录人：洪梦瑶"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "86cacd0b",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "\n",
    "> 1. random模块\n",
    "* random.random():生成0-1之间的伪随机数（浮点型数）\n",
    "* random.randint(a,b)：生成a-b之间的任意整数\n",
    "* random.choice(['a','b','c'])：随机生成一个序列中的值（非空）\n",
    "> 2. time模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cc85a998",
   "metadata": {},
   "source": [
    "# 1.random模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "da4f3313",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 1. random\n",
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "5a2fba1a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.8062693931756522"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "fcb3a66d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function random:\n",
      "\n",
      "random() method of random.Random instance\n",
      "    random() -> x in the interval [0, 1).\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.random)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "96c6b543",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method randint in module random:\n",
      "\n",
      "randint(a, b) method of random.Random instance\n",
      "    Return random integer in range [a, b], including both end points.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "## 2.randint\n",
    "help(random.randint)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "91b6839b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(1,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "23cb2a79",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n",
      "2\n",
      "2\n",
      "1\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(random.randint(1,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "9a93e915",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 3. random.choice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "c7f67486",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method choice in module random:\n",
      "\n",
      "choice(seq) method of random.Random instance\n",
      "    Choose a random element from a non-empty sequence.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.choice)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "4710ba60",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'a'"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.choice(['a','b','c'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b017c58f",
   "metadata": {},
   "source": [
    "# 2.time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "58cb60ec",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "969eeacb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sleep in module time:\n",
      "\n",
      "sleep(...)\n",
      "    sleep(seconds)\n",
      "    \n",
      "    Delay execution for a given number of seconds.  The argument may be\n",
      "    a floating point number for subsecond precision.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time.sleep)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "b8c42bc9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n",
      "world\n"
     ]
    }
   ],
   "source": [
    "print(\"hello\")\n",
    "time.sleep(3)\n",
    "print(\"world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "723ec04c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/xxyw/index0.htm\n",
      "https://www.nfu.edu.cn/xxyw/index1.htm\n",
      "https://www.nfu.edu.cn/xxyw/index2.htm\n",
      "https://www.nfu.edu.cn/xxyw/index3.htm\n",
      "https://www.nfu.edu.cn/xxyw/index4.htm\n"
     ]
    }
   ],
   "source": [
    "### 实战练习：快速生成 某个网站的所有代码的URL队列\n",
    "南方学院学校要闻 = \"https://www.nfu.edu.cn/xxyw/index\"\n",
    "\n",
    "页面后缀 = \".htm\"\n",
    "page = 5\n",
    "\n",
    "for i in range(page):\n",
    "    print(南方学院学校要闻 + str(i) + 页面后缀)\n",
    "    time.sleep(random.randint(1,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "1c029a2f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/xxyw/index0.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index1.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index2.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index3.htm\n",
      "该次停留 3 秒\n",
      "https://www.nfu.edu.cn/xxyw/index4.htm\n",
      "该次停留 4 秒\n"
     ]
    }
   ],
   "source": [
    "### 实战练习：快速生成 某个网站的所有代码的URL队列\n",
    "南方学院学校要闻 = \"https://www.nfu.edu.cn/xxyw/index\"\n",
    "\n",
    "页面后缀 = \".htm\"\n",
    "page = 5\n",
    "\n",
    "for i in range(page):\n",
    "    print(南方学院学校要闻 + str(i) + 页面后缀)\n",
    "    random_num = random.randint(1,5)\n",
    "    print(\"该次停留\",random_num,\"秒\")\n",
    "    time.sleep(random_num)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "46e3f934",
   "metadata": {},
   "source": [
    "# 3.课本实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "f0a7cee0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "29\n",
      "现在是秒/时间为奇数\n",
      "等待时间为： 4\n",
      "33\n",
      "现在是秒/时间为奇数\n",
      "等待时间为： 2\n",
      "35\n",
      "现在是秒/时间为奇数\n",
      "等待时间为： 5\n",
      "现在是秒/时间为偶数\n",
      "42\n",
      "等待时间为： 5\n",
      "45\n",
      "现在是秒/时间为奇数\n",
      "等待时间为： 1\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "import time,random\n",
    "\n",
    "odds=[ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59 ]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "\n",
    "for i in range(5):\n",
    "    right_this_second = datetime.datetime.today().second\n",
    "    if right_this_second in odds:\n",
    "        print(right_this_second)\n",
    "        print(\"现在是秒/时间为奇数\")\n",
    "    else:\n",
    "        print(\"现在是秒/时间为偶数\")\n",
    "        print(right_this_minute)\n",
    "        \n",
    "    wait_time = random.randint(1,5)\n",
    "    print(\"等待时间为：\",wait_time)\n",
    "    time.sleep(wait_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "9dc79a36",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles 在啤酒墙上``\n",
      "99 bottles 啤酒``\n",
      "拿一瓶走\n",
      "98 bottles 在啤酒墙上\n",
      "\n",
      "98 bottles 在啤酒墙上``\n",
      "98 bottles 啤酒``\n",
      "拿一瓶走\n",
      "97 bottles 在啤酒墙上\n",
      "\n",
      "97 bottles 在啤酒墙上``\n",
      "97 bottles 啤酒``\n",
      "拿一瓶走\n",
      "96 bottles 在啤酒墙上\n",
      "\n",
      "96 bottles 在啤酒墙上``\n",
      "96 bottles 啤酒``\n",
      "拿一瓶走\n",
      "95 bottles 在啤酒墙上\n",
      "\n",
      "95 bottles 在啤酒墙上``\n",
      "95 bottles 啤酒``\n",
      "拿一瓶走\n",
      "94 bottles 在啤酒墙上\n",
      "\n",
      "94 bottles 在啤酒墙上``\n",
      "94 bottles 啤酒``\n",
      "拿一瓶走\n",
      "93 bottles 在啤酒墙上\n",
      "\n",
      "93 bottles 在啤酒墙上``\n",
      "93 bottles 啤酒``\n",
      "拿一瓶走\n",
      "92 bottles 在啤酒墙上\n",
      "\n",
      "92 bottles 在啤酒墙上``\n",
      "92 bottles 啤酒``\n",
      "拿一瓶走\n",
      "91 bottles 在啤酒墙上\n",
      "\n",
      "91 bottles 在啤酒墙上``\n",
      "91 bottles 啤酒``\n",
      "拿一瓶走\n",
      "90 bottles 在啤酒墙上\n",
      "\n",
      "90 bottles 在啤酒墙上``\n",
      "90 bottles 啤酒``\n",
      "拿一瓶走\n",
      "89 bottles 在啤酒墙上\n",
      "\n",
      "89 bottles 在啤酒墙上``\n",
      "89 bottles 啤酒``\n",
      "拿一瓶走\n",
      "88 bottles 在啤酒墙上\n",
      "\n",
      "88 bottles 在啤酒墙上``\n",
      "88 bottles 啤酒``\n",
      "拿一瓶走\n",
      "87 bottles 在啤酒墙上\n",
      "\n",
      "87 bottles 在啤酒墙上``\n",
      "87 bottles 啤酒``\n",
      "拿一瓶走\n",
      "86 bottles 在啤酒墙上\n",
      "\n",
      "86 bottles 在啤酒墙上``\n",
      "86 bottles 啤酒``\n",
      "拿一瓶走\n",
      "85 bottles 在啤酒墙上\n",
      "\n",
      "85 bottles 在啤酒墙上``\n",
      "85 bottles 啤酒``\n",
      "拿一瓶走\n",
      "84 bottles 在啤酒墙上\n",
      "\n",
      "84 bottles 在啤酒墙上``\n",
      "84 bottles 啤酒``\n",
      "拿一瓶走\n",
      "83 bottles 在啤酒墙上\n",
      "\n",
      "83 bottles 在啤酒墙上``\n",
      "83 bottles 啤酒``\n",
      "拿一瓶走\n",
      "82 bottles 在啤酒墙上\n",
      "\n",
      "82 bottles 在啤酒墙上``\n",
      "82 bottles 啤酒``\n",
      "拿一瓶走\n",
      "81 bottles 在啤酒墙上\n",
      "\n",
      "81 bottles 在啤酒墙上``\n",
      "81 bottles 啤酒``\n",
      "拿一瓶走\n",
      "80 bottles 在啤酒墙上\n",
      "\n",
      "80 bottles 在啤酒墙上``\n",
      "80 bottles 啤酒``\n",
      "拿一瓶走\n",
      "79 bottles 在啤酒墙上\n",
      "\n",
      "79 bottles 在啤酒墙上``\n",
      "79 bottles 啤酒``\n",
      "拿一瓶走\n",
      "78 bottles 在啤酒墙上\n",
      "\n",
      "78 bottles 在啤酒墙上``\n",
      "78 bottles 啤酒``\n",
      "拿一瓶走\n",
      "77 bottles 在啤酒墙上\n",
      "\n",
      "77 bottles 在啤酒墙上``\n",
      "77 bottles 啤酒``\n",
      "拿一瓶走\n",
      "76 bottles 在啤酒墙上\n",
      "\n",
      "76 bottles 在啤酒墙上``\n",
      "76 bottles 啤酒``\n",
      "拿一瓶走\n",
      "75 bottles 在啤酒墙上\n",
      "\n",
      "75 bottles 在啤酒墙上``\n",
      "75 bottles 啤酒``\n",
      "拿一瓶走\n",
      "74 bottles 在啤酒墙上\n",
      "\n",
      "74 bottles 在啤酒墙上``\n",
      "74 bottles 啤酒``\n",
      "拿一瓶走\n",
      "73 bottles 在啤酒墙上\n",
      "\n",
      "73 bottles 在啤酒墙上``\n",
      "73 bottles 啤酒``\n",
      "拿一瓶走\n",
      "72 bottles 在啤酒墙上\n",
      "\n",
      "72 bottles 在啤酒墙上``\n",
      "72 bottles 啤酒``\n",
      "拿一瓶走\n",
      "71 bottles 在啤酒墙上\n",
      "\n",
      "71 bottles 在啤酒墙上``\n",
      "71 bottles 啤酒``\n",
      "拿一瓶走\n",
      "70 bottles 在啤酒墙上\n",
      "\n",
      "70 bottles 在啤酒墙上``\n",
      "70 bottles 啤酒``\n",
      "拿一瓶走\n",
      "69 bottles 在啤酒墙上\n",
      "\n",
      "69 bottles 在啤酒墙上``\n",
      "69 bottles 啤酒``\n",
      "拿一瓶走\n",
      "68 bottles 在啤酒墙上\n",
      "\n",
      "68 bottles 在啤酒墙上``\n",
      "68 bottles 啤酒``\n",
      "拿一瓶走\n",
      "67 bottles 在啤酒墙上\n",
      "\n",
      "67 bottles 在啤酒墙上``\n",
      "67 bottles 啤酒``\n",
      "拿一瓶走\n",
      "66 bottles 在啤酒墙上\n",
      "\n",
      "66 bottles 在啤酒墙上``\n",
      "66 bottles 啤酒``\n",
      "拿一瓶走\n",
      "65 bottles 在啤酒墙上\n",
      "\n",
      "65 bottles 在啤酒墙上``\n",
      "65 bottles 啤酒``\n",
      "拿一瓶走\n",
      "64 bottles 在啤酒墙上\n",
      "\n",
      "64 bottles 在啤酒墙上``\n",
      "64 bottles 啤酒``\n",
      "拿一瓶走\n",
      "63 bottles 在啤酒墙上\n",
      "\n",
      "63 bottles 在啤酒墙上``\n",
      "63 bottles 啤酒``\n",
      "拿一瓶走\n",
      "62 bottles 在啤酒墙上\n",
      "\n",
      "62 bottles 在啤酒墙上``\n",
      "62 bottles 啤酒``\n",
      "拿一瓶走\n",
      "61 bottles 在啤酒墙上\n",
      "\n",
      "61 bottles 在啤酒墙上``\n",
      "61 bottles 啤酒``\n",
      "拿一瓶走\n",
      "60 bottles 在啤酒墙上\n",
      "\n",
      "60 bottles 在啤酒墙上``\n",
      "60 bottles 啤酒``\n",
      "拿一瓶走\n",
      "59 bottles 在啤酒墙上\n",
      "\n",
      "59 bottles 在啤酒墙上``\n",
      "59 bottles 啤酒``\n",
      "拿一瓶走\n",
      "58 bottles 在啤酒墙上\n",
      "\n",
      "58 bottles 在啤酒墙上``\n",
      "58 bottles 啤酒``\n",
      "拿一瓶走\n",
      "57 bottles 在啤酒墙上\n",
      "\n",
      "57 bottles 在啤酒墙上``\n",
      "57 bottles 啤酒``\n",
      "拿一瓶走\n",
      "56 bottles 在啤酒墙上\n",
      "\n",
      "56 bottles 在啤酒墙上``\n",
      "56 bottles 啤酒``\n",
      "拿一瓶走\n",
      "55 bottles 在啤酒墙上\n",
      "\n",
      "55 bottles 在啤酒墙上``\n",
      "55 bottles 啤酒``\n",
      "拿一瓶走\n",
      "54 bottles 在啤酒墙上\n",
      "\n",
      "54 bottles 在啤酒墙上``\n",
      "54 bottles 啤酒``\n",
      "拿一瓶走\n",
      "53 bottles 在啤酒墙上\n",
      "\n",
      "53 bottles 在啤酒墙上``\n",
      "53 bottles 啤酒``\n",
      "拿一瓶走\n",
      "52 bottles 在啤酒墙上\n",
      "\n",
      "52 bottles 在啤酒墙上``\n",
      "52 bottles 啤酒``\n",
      "拿一瓶走\n",
      "51 bottles 在啤酒墙上\n",
      "\n",
      "51 bottles 在啤酒墙上``\n",
      "51 bottles 啤酒``\n",
      "拿一瓶走\n",
      "50 bottles 在啤酒墙上\n",
      "\n",
      "50 bottles 在啤酒墙上``\n",
      "50 bottles 啤酒``\n",
      "拿一瓶走\n",
      "49 bottles 在啤酒墙上\n",
      "\n",
      "49 bottles 在啤酒墙上``\n",
      "49 bottles 啤酒``\n",
      "拿一瓶走\n",
      "48 bottles 在啤酒墙上\n",
      "\n",
      "48 bottles 在啤酒墙上``\n",
      "48 bottles 啤酒``\n",
      "拿一瓶走\n",
      "47 bottles 在啤酒墙上\n",
      "\n",
      "47 bottles 在啤酒墙上``\n",
      "47 bottles 啤酒``\n",
      "拿一瓶走\n",
      "46 bottles 在啤酒墙上\n",
      "\n",
      "46 bottles 在啤酒墙上``\n",
      "46 bottles 啤酒``\n",
      "拿一瓶走\n",
      "45 bottles 在啤酒墙上\n",
      "\n",
      "45 bottles 在啤酒墙上``\n",
      "45 bottles 啤酒``\n",
      "拿一瓶走\n",
      "44 bottles 在啤酒墙上\n",
      "\n",
      "44 bottles 在啤酒墙上``\n",
      "44 bottles 啤酒``\n",
      "拿一瓶走\n",
      "43 bottles 在啤酒墙上\n",
      "\n",
      "43 bottles 在啤酒墙上``\n",
      "43 bottles 啤酒``\n",
      "拿一瓶走\n",
      "42 bottles 在啤酒墙上\n",
      "\n",
      "42 bottles 在啤酒墙上``\n",
      "42 bottles 啤酒``\n",
      "拿一瓶走\n",
      "41 bottles 在啤酒墙上\n",
      "\n",
      "41 bottles 在啤酒墙上``\n",
      "41 bottles 啤酒``\n",
      "拿一瓶走\n",
      "40 bottles 在啤酒墙上\n",
      "\n",
      "40 bottles 在啤酒墙上``\n",
      "40 bottles 啤酒``\n",
      "拿一瓶走\n",
      "39 bottles 在啤酒墙上\n",
      "\n",
      "39 bottles 在啤酒墙上``\n",
      "39 bottles 啤酒``\n",
      "拿一瓶走\n",
      "38 bottles 在啤酒墙上\n",
      "\n",
      "38 bottles 在啤酒墙上``\n",
      "38 bottles 啤酒``\n",
      "拿一瓶走\n",
      "37 bottles 在啤酒墙上\n",
      "\n",
      "37 bottles 在啤酒墙上``\n",
      "37 bottles 啤酒``\n",
      "拿一瓶走\n",
      "36 bottles 在啤酒墙上\n",
      "\n",
      "36 bottles 在啤酒墙上``\n",
      "36 bottles 啤酒``\n",
      "拿一瓶走\n",
      "35 bottles 在啤酒墙上\n",
      "\n",
      "35 bottles 在啤酒墙上``\n",
      "35 bottles 啤酒``\n",
      "拿一瓶走\n",
      "34 bottles 在啤酒墙上\n",
      "\n",
      "34 bottles 在啤酒墙上``\n",
      "34 bottles 啤酒``\n",
      "拿一瓶走\n",
      "33 bottles 在啤酒墙上\n",
      "\n",
      "33 bottles 在啤酒墙上``\n",
      "33 bottles 啤酒``\n",
      "拿一瓶走\n",
      "32 bottles 在啤酒墙上\n",
      "\n",
      "32 bottles 在啤酒墙上``\n",
      "32 bottles 啤酒``\n",
      "拿一瓶走\n",
      "31 bottles 在啤酒墙上\n",
      "\n",
      "31 bottles 在啤酒墙上``\n",
      "31 bottles 啤酒``\n",
      "拿一瓶走\n",
      "30 bottles 在啤酒墙上\n",
      "\n",
      "30 bottles 在啤酒墙上``\n",
      "30 bottles 啤酒``\n",
      "拿一瓶走\n",
      "29 bottles 在啤酒墙上\n",
      "\n",
      "29 bottles 在啤酒墙上``\n",
      "29 bottles 啤酒``\n",
      "拿一瓶走\n",
      "28 bottles 在啤酒墙上\n",
      "\n",
      "28 bottles 在啤酒墙上``\n",
      "28 bottles 啤酒``\n",
      "拿一瓶走\n",
      "27 bottles 在啤酒墙上\n",
      "\n",
      "27 bottles 在啤酒墙上``\n",
      "27 bottles 啤酒``\n",
      "拿一瓶走\n",
      "26 bottles 在啤酒墙上\n",
      "\n",
      "26 bottles 在啤酒墙上``\n",
      "26 bottles 啤酒``\n",
      "拿一瓶走\n",
      "25 bottles 在啤酒墙上\n",
      "\n",
      "25 bottles 在啤酒墙上``\n",
      "25 bottles 啤酒``\n",
      "拿一瓶走\n",
      "24 bottles 在啤酒墙上\n",
      "\n",
      "24 bottles 在啤酒墙上``\n",
      "24 bottles 啤酒``\n",
      "拿一瓶走\n",
      "23 bottles 在啤酒墙上\n",
      "\n",
      "23 bottles 在啤酒墙上``\n",
      "23 bottles 啤酒``\n",
      "拿一瓶走\n",
      "22 bottles 在啤酒墙上\n",
      "\n",
      "22 bottles 在啤酒墙上``\n",
      "22 bottles 啤酒``\n",
      "拿一瓶走\n",
      "21 bottles 在啤酒墙上\n",
      "\n",
      "21 bottles 在啤酒墙上``\n",
      "21 bottles 啤酒``\n",
      "拿一瓶走\n",
      "20 bottles 在啤酒墙上\n",
      "\n",
      "20 bottles 在啤酒墙上``\n",
      "20 bottles 啤酒``\n",
      "拿一瓶走\n",
      "19 bottles 在啤酒墙上\n",
      "\n",
      "19 bottles 在啤酒墙上``\n",
      "19 bottles 啤酒``\n",
      "拿一瓶走\n",
      "18 bottles 在啤酒墙上\n",
      "\n",
      "18 bottles 在啤酒墙上``\n",
      "18 bottles 啤酒``\n",
      "拿一瓶走\n",
      "17 bottles 在啤酒墙上\n",
      "\n",
      "17 bottles 在啤酒墙上``\n",
      "17 bottles 啤酒``\n",
      "拿一瓶走\n",
      "16 bottles 在啤酒墙上\n",
      "\n",
      "16 bottles 在啤酒墙上``\n",
      "16 bottles 啤酒``\n",
      "拿一瓶走\n",
      "15 bottles 在啤酒墙上\n",
      "\n",
      "15 bottles 在啤酒墙上``\n",
      "15 bottles 啤酒``\n",
      "拿一瓶走\n",
      "14 bottles 在啤酒墙上\n",
      "\n",
      "14 bottles 在啤酒墙上``\n",
      "14 bottles 啤酒``\n",
      "拿一瓶走\n",
      "13 bottles 在啤酒墙上\n",
      "\n",
      "13 bottles 在啤酒墙上``\n",
      "13 bottles 啤酒``\n",
      "拿一瓶走\n",
      "12 bottles 在啤酒墙上\n",
      "\n",
      "12 bottles 在啤酒墙上``\n",
      "12 bottles 啤酒``\n",
      "拿一瓶走\n",
      "11 bottles 在啤酒墙上\n",
      "\n",
      "11 bottles 在啤酒墙上``\n",
      "11 bottles 啤酒``\n",
      "拿一瓶走\n",
      "10 bottles 在啤酒墙上\n",
      "\n",
      "10 bottles 在啤酒墙上``\n",
      "10 bottles 啤酒``\n",
      "拿一瓶走\n",
      "9 bottles 在啤酒墙上\n",
      "\n",
      "9 bottles 在啤酒墙上``\n",
      "9 bottles 啤酒``\n",
      "拿一瓶走\n",
      "8 bottles 在啤酒墙上\n",
      "\n",
      "8 bottles 在啤酒墙上``\n",
      "8 bottles 啤酒``\n",
      "拿一瓶走\n",
      "7 bottles 在啤酒墙上\n",
      "\n",
      "7 bottles 在啤酒墙上``\n",
      "7 bottles 啤酒``\n",
      "拿一瓶走\n",
      "6 bottles 在啤酒墙上\n",
      "\n",
      "6 bottles 在啤酒墙上``\n",
      "6 bottles 啤酒``\n",
      "拿一瓶走\n",
      "5 bottles 在啤酒墙上\n",
      "\n",
      "5 bottles 在啤酒墙上``\n",
      "5 bottles 啤酒``\n",
      "拿一瓶走\n",
      "4 bottles 在啤酒墙上\n",
      "\n",
      "4 bottles 在啤酒墙上``\n",
      "4 bottles 啤酒``\n",
      "拿一瓶走\n",
      "3 bottles 在啤酒墙上\n",
      "\n",
      "3 bottles 在啤酒墙上``\n",
      "3 bottles 啤酒``\n",
      "拿一瓶走\n",
      "2 bottles 在啤酒墙上\n",
      "\n",
      "2 bottles 在啤酒墙上``\n",
      "2 bottles 啤酒``\n",
      "拿一瓶走\n",
      "1 bottle 在啤酒墙上\n",
      "\n",
      "1 bottle 在啤酒墙上``\n",
      "1 bottle 啤酒``\n",
      "拿一瓶走\n",
      "只剩一瓶，不能给你了！\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 项目3 P44\n",
    "word = \"bottles\"\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"在啤酒墙上``\")\n",
    "    print(beer_num,word,\"啤酒``\")\n",
    "    print(\"拿一瓶走\")\n",
    "    if beer_num == 1:\n",
    "        print(\"只剩一瓶，不能给你了！\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "        print(new_num,word,\"在啤酒墙上\")\n",
    "    print() # print()这一行代码表示空一行"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ede7daf2",
   "metadata": {},
   "source": [
    "## 课后任务：预习\n",
    "* 思考：什么是有序的数据（Sequence Yype？）\n",
    "* 预习：数字，字符串\n",
    "> [https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex] \n",
    ">> [https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0423d996",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
